<?php
namespace app\index\controller;
use app\common\controller\HomeBase;
use think\Db;
use think\Session;
use think\Cache;
use app\index\model\Guestbook;

class Gb extends HomeBase {

    private  $guestBook;
    protected function _initialize() {
        $this->guestBook = new Guestbook();
        parent::_initialize();

    }
    public function add()
    {

        if ($this->request->isPost()) {
            $data = input();
            $data['userip'] = getIPaddress();
            $data['os'] = getOS();
            $res = $this->guestBook->save($data);
            return json_encode($res);
        }
    }
}
